package com.mydemo.springlearning.functions.CRUDdemo.byxml.service.impl;

import com.mydemo.springlearning.functions.CRUDdemo.entity.User;
import com.mydemo.springlearning.functions.CRUDdemo.byxml.mapper.UserMapper;
import com.mydemo.springlearning.functions.CRUDdemo.byxml.service.UserService;
import com.mydemo.springlearning.functions.mb_interceptor.annotation.AmendSQL;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {


    private UserMapper userMapper;

    @Autowired
    private void setUserMapper(UserMapper userMapper) {
        this.userMapper = userMapper;
    }

    /**
     * 增加用户
     *
     * @param user 用户
     */
    @Override
    public void add(User user) {
        userMapper.insert(user);
    }

    @Override
    public void testIntroduction() {
        System.out.println("do testIntroduction");
    }

    /**
     * 得到所有用户
     *
     * @return 所有用户
     */
    @AmendSQL(sql = "select * from users")
    @Override
    public List<User> getAllUsers() {
        return userMapper.getAll();
    }
}
